package com.ruoyi.pms.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pms.domain.PmsTaskTransLog;
import com.ruoyi.pms.service.IPmsTaskTransLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务转移记录Controller
 *
 * @author huikai
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/pms/tasktranslog")
public class PmsTaskTransLogController extends BaseController
{
    @Autowired
    private IPmsTaskTransLogService pmsTaskTransLogService;

    /**
     * 查询任务转移记录列表
     */
    @PreAuthorize("@ss.hasPermi('pms:tasktranslog:list')")
    @GetMapping("/list")
    public TableDataInfo list(PmsTaskTransLog pmsTaskTransLog)
    {
        startPage();
        List<PmsTaskTransLog> list = pmsTaskTransLogService.selectPmsTaskTransLogList(pmsTaskTransLog);
        return getDataTable(list);
    }

    /**
     * 导出任务转移记录列表
     */
    @PreAuthorize("@ss.hasPermi('pms:tasktranslog:export')")
    @Log(title = "任务转移记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PmsTaskTransLog pmsTaskTransLog)
    {
        List<PmsTaskTransLog> list = pmsTaskTransLogService.selectPmsTaskTransLogList(pmsTaskTransLog);
        ExcelUtil<PmsTaskTransLog> util = new ExcelUtil<PmsTaskTransLog>(PmsTaskTransLog.class);
        util.exportExcel(response, list, "任务转移记录数据");
    }

    /**
     * 获取任务转移记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('pms:tasktranslog:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(pmsTaskTransLogService.getInfoByLogId(logId));
    }

    /**
     * 新增任务转移记录
     */
    @PreAuthorize("@ss.hasPermi('pms:tasktranslog:add')")
    @Log(title = "任务转移记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsTaskTransLog pmsTaskTransLog)
    {
        return toAjax(pmsTaskTransLogService.add(pmsTaskTransLog));
    }

    /**
     * 修改任务转移记录
     */
    @PreAuthorize("@ss.hasPermi('pms:tasktranslog:edit')")
    @Log(title = "任务转移记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsTaskTransLog pmsTaskTransLog)
    {
        return toAjax(pmsTaskTransLogService.edit(pmsTaskTransLog));
    }

    /**
     * 删除任务转移记录
     */
    @PreAuthorize("@ss.hasPermi('pms:tasktranslog:remove')")
    @Log(title = "任务转移记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(pmsTaskTransLogService.removeByLogIds(logIds));
    }
}